from channels.channels import Channel

class ReadFile2Lines(Channel):
    """
    Read file_path and convert to lines.
    File format: text
        我爱北京天安门，因为这是我的祖国的象征。
        我爱你。
    """
    required = ['file_path']
    send = ['lines']
    
    @staticmethod
    def execute(args={}, meta={}, lines=[], **kwargs):
        file_path = args.get('file_path', '')
        with open(file_path, 'r', encoding='utf-8') as fr:
            lines = fr.readlines()

            # bar show
            args.false_bar()

            return {
                'lines': lines
            }
